using System;
using System.Collections.Generic;
using Azure.Domain.Models;

namespace Azure.Web.Models
{
    public class PostListViewModel : List<PostListViewModel.Item>
    {
        public PostListViewModel()
        {
        }

        public PostListViewModel(IEnumerable<Post> posts)
        {
            if (posts == null) return;

            foreach (var post in posts)
            {
                Add(new Item(post));
            }
        }

        public class Item
        {
            public Item()
            {
            }

            public Item(Post post)
            {
                Title = post.Title;
                Created = post.Created;
                Slug = post.Slug;
                PartitionKey = post.PartitionKey;
                RowKey = post.RowKey;
            }

            public string Title { get; set; }
            public DateTime Created { get; set; }
            public string Slug { get; set; }
            public string PartitionKey { get; set; }
            public string RowKey { get; set; }
        }
    }
}